import { Tag } from 'ant-design-vue';
import { h } from 'vue';

export const form = {
  appId: '',
  size: 10,
  current: 1,
};

export const orderStatusMap = {
  '00': '正常',
  '01': '已结束',
  '02': '已过期',
  '05': '订单异常',
};

export const instanceStatusMap = {
  '00': '正常',
  '01': '已释放',
  '02': '已冻结',
  '04': '准备中',
  '05': '实例异常',
};

export const cmOrderActionColumns = [
  {
    key: 'orderId',
    title: '云商店订单ID',
    dataIndex: 'orderId',
    width: 120,
  },
  {
    key: 'businessId',
    title: '云商店业务ID',
    dataIndex: 'businessId',
    width: 120,
  },
  {
    key: 'customerId',
    title: '华为云domainId',
    dataIndex: 'customerId',
    width: 120,
  },
  {
    key: 'appName',
    title: '应用',
    dataIndex: 'appName',
    width: 60,
  },
  {
    key: 'skucode',
    title: '云商店产品规格标识',
    dataIndex: 'skucode',
    width: 120,
  },
  {
    key: 'productId',
    title: '云商店产品标识',
    dataIndex: 'productId',
    width: 120,
  },
  {
    key: 'orderInstanceId',
    title: '订单实例ID',
    dataIndex: 'orderInstanceId',
    width: 100,
  },
  {
    key: 'status',
    title: '订单状态',
    dataIndex: 'status',
    width: 70,
    customRender: ({ record }) => {
      const status = record.status;
      const statusMap = {
        '00': '正常',
        '01': '已结束',
        '02': '已过期',
        '05': '订单异常',
      };
      const color = status === '00' ? 'green' : 'red';
      return h(Tag, { color: color }, () => statusMap[status]);
    },
  },
  {
    key: 'activity',
    title: '接口请求标识',
    dataIndex: 'activity',
    width: 60,
  },
  {
    key: 'reqTimeStamp',
    title: '请求发起时间',
    dataIndex: 'reqTimeStamp',
    width: 100,
  },
  {
    key: 'operation',
    title: '操作',
    dataIndex: 'operation',
    fixed: 'right',
    width: 60,
  },
];
